package com.broadengate.action;
import java.util.Locale;   

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.broadengate.form.VoicePromptForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.Globals; 

public class VoicePromptAction extends Action{
	
	/******
	 * 实现语音提示
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward 对象
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response){

			   HttpSession session=request.getSession();
			   Locale locale =null;
			   VoicePromptForm voicePromptForm = (VoicePromptForm) form;
			   try {
				   session.setAttribute("ifsound",voicePromptForm.getTip());
				   
				 
				  if("Chinese".equals(voicePromptForm.getInternational())){
					  locale = new Locale("zh","CN");}
					  else if("English".equals(voicePromptForm.getInternational())){
						  locale=new Locale("en","US");		
				  } 
				   
				 session.setAttribute(Globals.LOCALE_KEY, locale); 
				 
				  return mapping.findForward("success");
			} catch (Exception e) {
				e.printStackTrace();
				return mapping.findForward("fail");
			}
				
	}
	
	
}
